package com.itheima.reggie.mappers;

import com.itheima.reggie.entity.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

public interface OrderMapper {
    @Insert("insert into orders values(#{id},#{number},#{status}," +
                    "#{userId},#{addressBookId},#{orderTime},#{checkoutTime}," +
                    "#{payMethod},#{amount},#{remark},#{phone},#{address}," +
                    "#{userName},#{consignee})")
    void save(Orders order);

    @Select("select * from orders where user_id=#{userId}")
    List<Orders> findByUserId(Long userId);

    List<Orders> findByNumberAndTime(@Param("number") Long number,
                                     @Param("beginTime") LocalDateTime beginTime,
                                     @Param("endTime") LocalDateTime endTime);
}
